<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>转正申请</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
</head>
<body>
	<div id="msg" align="center" style="padding-top: 40px;">
		正在验证人员工号……</div>
	<script type="text/javascript">
	
		var upWindow = window.parent.frames["zwIframe"];
		if (!upWindow) {
    upWindow = window.parent.frames["componentDiv"].frames["zwIframe"];
}

		var designClass = "design_class", hideClass = "hide_class", browseClass = "browse_class", addClass = "add_class", editClass = "edit_class";

		function fy_dialog_close() {
			window.parent.$(".mask").remove();
			window.parent.parent.$(".layui-layer-iframe").parent().find(".layui-layer-close").trigger("click");
		
		}
		function getUpFieldsByFieldval(name) {
		
			return upWindow.$("[fieldval*='displayName:\"" + name + "\"']");
			
		}

		function getUpFieldValue(field) {
		
			var fieldVal = field.attr("fieldVal");
			var editTag = field.hasClass(editClass);
			var browseTag = field.hasClass(browseClass);
			var addTag = field.hasClass(addClass);
			if (fieldVal != null && typeof (fieldVal) != 'undefined') {
				fieldVal = eval("(" + fieldVal + ")");
			} else {
				return null;
			}
			var obj = new Object();
			obj.displayName = fieldVal.displayName;
			obj.name = fieldVal.name;
			var tag = true;
			switch (fieldVal.inputType) {
			case "text":
			case "textarea":
				if (editTag) {
					obj.value = field.find("#" + fieldVal.name).val();
				} else if (browseTag) {
					obj.value = fieldVal.value;
				} else if (addTag) {
					obj.value = field.find("#" + fieldVal.name).val();
				}
				break;
			default:
				tag = false;
			}
			if (obj.value != undefined) {
				obj.value = obj.value.replace("\r\n", ";");
				obj.value = obj.value.replace("\n", ";");
			}
			return obj;
		}

		function setUpFieldValue2(field, value, displayValue, index) {
		
			var fieldVal = field.attr("fieldVal");
			var editTag = field.hasClass(editClass);
			var browseTag = field.hasClass(browseClass);
			var addTag = field.hasClass(addClass);
			if (fieldVal != null && typeof (fieldVal) != 'undefined') {
				fieldVal = eval("(" + fieldVal + ")");
			} else {
				return null;
			}
			var tag = true;
			switch (fieldVal.inputType) {
			case "text":
			case "textarea":
				if (editTag) {
					field.find("#" + fieldVal.name).val(value);
					field.find("#" + fieldVal.name).trigger("blur");
				} else if (addTag) {
					field.find("#" + fieldVal.name).val(
							field.find("#" + fieldVal.name).val() + value);
					field.find("#" + fieldVal.name).trigger("blur");
				}
				break;
			case "date":
				if (editTag) {
					field.find("#" + fieldVal.name).val(value);
					field.find("#" + fieldVal.name).trigger("blur");
				}
				break;
			}
		}
		<!--转正申请 -->
		var Code = [];
		var CodeInputArray = getUpFieldsByFieldval("工号");
		var NameInput=getUpFieldsByFieldval("姓名");
		var	DeptInput=getUpFieldsByFieldval("部门车间");
		var	JobInput=getUpFieldsByFieldval("岗位");
		var	BirthdateInput=getUpFieldsByFieldval("出生日期");
		var	NationalityInput=getUpFieldsByFieldval("民族");
		var	NativeplaceInput=getUpFieldsByFieldval("籍贯");
		var	SexInput=getUpFieldsByFieldval("性别");
		var Indutydate=getUpFieldsByFieldval("到岗日期");
		
		if (CodeInputArray.length > 0) {			
				length = CodeInputArray.length;			
			} 
		function init() {
			for (var i = 0; i < length; i++) {
				Code.push(getUpFieldValue(CodeInputArray.eq(i)).value);
			}
		}
		function load() {
			if (window.XMLHttpRequest) {
				xmlObj = new XMLHttpRequest();
			} else {
				if (window.ActiveXObject) {
					xmlObj = new ActiveXObject("Microsoft.XMLHTTP");//java定义XMLHTTP对象的方法
				} else {
					return;
				}
			}
			xmlObj.onreadystatechange = handleResponse;
			xmlObj.open("get",
					"./oa2hrController.do?method=writepositivelJSP&Code="+ Code, true);
			xmlObj.send();//发送

		}
			function handleResponse() {
			
				if (xmlObj.readyState == 4){
				 var success = false;
			
					if (xmlObj.status == 200) {
					
						var datas = eval("[" + xmlObj.responseText + "]");
					//	var datas = JSON.parse(xmlObj.responseText);
					if (datas.length == 1) {
						 var codeMap = datas[0];
						 for (var i = 0, length =  CodeInputArray.length; i < length; i++) {
						 var code = codeMap["code"+ getUpFieldValue(CodeInputArray.eq(i)).value];						 
						 if(code){
						  setUpFieldValue2(NameInput,code["name"]);
						  setUpFieldValue2(DeptInput,code["dept"]);
						  setUpFieldValue2(JobInput,code["job"]);
						  setUpFieldValue2(BirthdateInput,code["birthdate"]);
						 // setUpFieldValue2(NationalityInput,code["nationality"]);
						 // setUpFieldValue2(NativeplaceInput,code["nativeplace"]);
						  setUpFieldValue2(SexInput,code["sex"]);
						  setUpFieldValue2(Indutydate,code["indutydate"]);
						 	}						            
						             success = true;
						 }
						}
					}
				if (!success) {
					alert("请检查输入的工号");
				}
				fy_dialog_close();
				}
			}
		init();//初始化
		load();//加载
	</script>
<html></html>
</body>
</html>
